package com.some;

import java.util.Scanner;

public class AliLi {

    public int result(int x, int y) {
        Scanner scanner = new Scanner(System.in);
        x = scanner.nextInt();
        y = scanner.nextInt();
        int sum = 0;
        int[][] nums = new int[x][y];
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < y; j++) {
                nums[i][j] = scanner.nextInt();
            }
        }
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < y; j++) {
                if (nums[i][j] == 0) {
                    // sum +=search(i, j, nums);
                    for (int i1 = 0; i1 < nums[0].length; i1++) {
                        if (nums[i][i1] == 1) {
                            sum++;
                        }
                    }
                    for (int[] num : nums) {
                        if (num[j] == 1) {
                            sum++;
                        }
                    }
                }
            }
        }
        return sum;
    }

    // 查找出某个路灯可以照亮的人数
    int search(int x, int y, int[][] nums) {
        int sum = 0;
        for (int i = 0; i < nums[0].length; i++) {
            if (nums[x][i] == 1) {
                sum++;
            }
        }
        for (int[] num : nums) {
            if (num[y] == 1) {
                sum++;
            }
        }
        return sum;
    }


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int sum = 0;
        int[][] nums = new int[x][y];
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < y; j++) {
                nums[i][j] = scanner.nextInt();
            }
        }
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < y; j++) {
                if (nums[i][j] == 0) {
                    // 上
                    for (int k = 0; k < i; k++) {
                        if (nums[k][j] == 1) {
                            sum++;
                            break;
                        }
                    }
                    // 下
                    for (int k = i + 1; k < nums.length; k++) {
                        if (nums[k][j] == 1) {
                            sum++;
                            break;
                        }
                    }
                    // 左
                    for (int k = 0; k < j; k++) {
                        if (nums[i][k] == 1) {
                            sum++;
                            break;
                        }
                    }
                    // 右
                    for (int k = j + 1; k < nums[0].length; k++) {
                        if (nums[i][k] == 1) {
                            sum++;
                            break;
                        }
                    }
                }
            }
        }
        System.out.println(sum);
    }
}
